package weather.language;

import java.util.*;

/**
 * @author Jerzy Mazurek WEiTI PW
 */
public class Site
{
	public Site(String mainName)
	{
		this.mainName = mainName;
		this.allNames.add(mainName);
	}
	
	public Site(String mainName, Set<String> otherNames)
	{
		this(mainName);
		
		for (String otherName: otherNames)
			this.allNames.add(otherName);
	}
	
	public String getMainName()
	{
		return mainName;
	}
	
	public String[] getAllNames()
	{
		return allNames.toArray(new String[0]);
	}
	
	@Override
	public String toString()
	{
		return mainName;
	}
	
	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		
		result = prime * result + ((mainName == null) ? 0 : mainName.hashCode());
		
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		
		Site other = (Site) obj;
		
		if (mainName == null)
		{
			if (other.mainName != null)
				return false;
		}
		else if (!mainName.equals(other.mainName))
			return false;
		
		return true;
	}

	private String mainName;
	private Set<String> allNames = new HashSet<String>();
}
